import { getList } from '@/api/house/repair'
import { getOptions } from '@/api/option'
import {isIntegerBig} from "../../../utils/validate";

export default {
  data() {
    return {
      payId: '',
      formVisible: false,
      formTitle: '缴费信息',
      imgVisible1: false,
      imgTitle1: '报修附件',
      imgVisible2: false,
      imgTitle2: '修理反馈附件',
      form:{},
      listQuery: {
        page: 1,
        limit: 20,
        code: '',
        applyMobile: '',
        state: '',
        feeState: ''
      },
      total: 0,
      list: null,
      listLoading: true,
      selRow: {},
      options:{
        repairState: [],
        feeState: []
      },
      applyImages:[
        {
          url: 'http://127.0.0.1:81/3a01e064-a039-4d03-ae27-ab1e5c594277.jpg',
          title: 'pic1'
        },
        {
          url: 'http://127.0.0.1:81/3ee0edbc-5c83-4d33-8396-2ad542316bad.jpg',
          title: 'pic1'
        }
      ]
    }
  },
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: 'success',
        draft: 'gray',
        deleted: 'danger'
      }
      return statusMap[status]
    }
  },
  created() {
    this.init()
    this.initOptions()
  },
  computed: {

    //表单验证
    rules() {
    }
  },
  methods: {
    init() {
      this.fetchData()
    },
    initOptions(){
      getOptions('RepairState_FeeState').then(response => {
        this.options.repairState = response.data.maps.RepairState;
        this.options.feeState = response.data.maps.FeeState;
      })
    },
    fetchData() {
      this.listLoading = true
      console.log("query="+JSON.stringify(this.listQuery))
      getList(this.listQuery).then(response => {
        this.list = response.data.records
        this.listLoading = false
        this.total = response.data.total
      })

    },

    reset() {
      this.listQuery.code = ''
      this.listQuery.applyMobile = ''
      this.listQuery.state = ''
      this.listQuery.feeState = ''
      this.fetchData()
    },
    viewPayInfo(payId){
      console.log('------payId='+payId)
      //TODO 拉取缴费信息
      this.formTitle = '缴费信息';
      this.formVisible = true;
      this.payId = payId;
    },

    viewApplyPics(id){
      console.log('------id='+id)
      //TODO 拉取报修申请附件列表
      this.imgVisible1 = true;
    },

    search() {
      this.fetchData()
    },

    handleFilter() {
      this.listQuery.page = 1
      this.getList()
    },
    handleClose() {

    },
    fetchNext() {
      this.listQuery.page = this.listQuery.page + 1
      this.fetchData()
    },
    fetchPrev() {
      this.listQuery.page = this.listQuery.page - 1
      this.fetchData()
    },
    fetchPage(page) {
      this.listQuery.page = page
      this.fetchData()
    },
    changeSize(limit) {
      this.listQuery.limit = limit
      this.fetchData()
    },
    handleCurrentChange(currentRow, oldCurrentRow) {
      this.selRow = currentRow
    }


  }
}
